/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package almacen;

import java.io.FileOutputStream;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Properties;
import java.util.logging.Level;
import javax.swing.ImageIcon;
import resources.jcProperties;

/**
 *
 * @author pato
 */
public class cambiarConexion extends javax.swing.JDialog {
Properties propiedades;
jcProperties editarPropiedades;
    Connection con = null;
    /**
     * Creates new form cambiarConexion
     * @param parent
     * @param modal
     */
public cambiarConexion(java.awt.Frame parent, boolean modal){
        super(parent, modal);
        initComponents();
  try{
        // Carga datos de conexion Remota
        editarPropiedades = new jcProperties();
        propiedades = new Properties();
        propiedades = editarPropiedades.getProperties();
        jLabel8.setText(propiedades.getProperty("serverLocal"));
        jLabel9.setText(propiedades.getProperty("usuarioLocal"));
        jLabel10.setText(propiedades.getProperty("baseDatosLocal"));
        // Carga datos de Conexion WEB
        serverWeb.setText(propiedades.getProperty("serverRemoto"));
        usuarioWeb.setText(propiedades.getProperty("usuarioRemoto"));
        DBWeb.setText(propiedades.getProperty("baseDatosRemoto"));
        lblSufijo.setText(propiedades.getProperty("sufijo"));
    }
  catch (Exception ex) {
    Almacen.logger.log(Level.SEVERE, null, ex);
  }
}

    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        tabsConexion = new javax.swing.JTabbedPane();
        tabRemota = new javax.swing.JPanel();
        jPasswordField1 = new javax.swing.JPasswordField();
        jTextField2 = new javax.swing.JTextField();
        jButton3 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jTextField1 = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        tabLocal = new javax.swing.JPanel();
        buttonSaveWeb = new javax.swing.JButton();
        DBWeb = new javax.swing.JLabel();
        textUserWeb = new javax.swing.JTextField();
        serverWeb = new javax.swing.JLabel();
        textServerWeb = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        buttonTestDBWeb = new javax.swing.JButton();
        buttonGetDBWeb = new javax.swing.JButton();
        textPassWeb = new javax.swing.JPasswordField();
        jLabel14 = new javax.swing.JLabel();
        comboDBWeb = new javax.swing.JComboBox();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        usuarioWeb = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        txtSufijo = new javax.swing.JTextField();
        jLabel20 = new javax.swing.JLabel();
        lblSufijo = new javax.swing.JLabel();
        jButton4 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Cambiar conexion");
        setIconImage(new ImageIcon(getClass().getResource("/resources/logo_rayito.png")).getImage());
        setResizable(false);

        jPasswordField1.setNextFocusableComponent(jButton1);
        jPasswordField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jPasswordField1ActionPerformed(evt);
            }
        });

        jTextField2.setNextFocusableComponent(jPasswordField1);

        jButton3.setText("Guardar Configuracion");
        jButton3.setEnabled(false);
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jButton2.setText("Probar Conexion");
        jButton2.setEnabled(false);
        jButton2.setNextFocusableComponent(jButton3);
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jTextField1.setNextFocusableComponent(jTextField2);

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel6.setText("Usuario:");

        jLabel1.setText("Servidor:");

        jLabel2.setText("Usuario:");

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel5.setText("Servidor Principal");

        jLabel3.setText("Contraseña:");

        jLabel9.setText("---");

        jLabel4.setText("Base De Datos:");

        jLabel8.setText("---");

        jLabel10.setText("---");

        jComboBox1.setEnabled(false);
        jComboBox1.setNextFocusableComponent(jButton2);

        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel7.setText("Base de Datos:");

        jButton1.setText("Obtener Bases De Datos");
        jButton1.setNextFocusableComponent(jComboBox1);
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout tabRemotaLayout = new javax.swing.GroupLayout(tabRemota);
        tabRemota.setLayout(tabRemotaLayout);
        tabRemotaLayout.setHorizontalGroup(
            tabRemotaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tabRemotaLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(tabRemotaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(tabRemotaLayout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addGap(18, 18, 18)
                        .addComponent(jPasswordField1))
                    .addGroup(tabRemotaLayout.createSequentialGroup()
                        .addGroup(tabRemotaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel2))
                        .addGap(34, 34, 34)
                        .addGroup(tabRemotaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jTextField1)
                            .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 151, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(tabRemotaLayout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(tabRemotaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jComboBox1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(tabRemotaLayout.createSequentialGroup()
                                .addGroup(tabRemotaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 151, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jButton1))
                                .addGap(0, 0, Short.MAX_VALUE)))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(tabRemotaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(tabRemotaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, tabRemotaLayout.createSequentialGroup()
                            .addComponent(jLabel6)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jLabel9))
                        .addGroup(tabRemotaLayout.createSequentialGroup()
                            .addComponent(jLabel5)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jLabel8)))
                    .addGroup(tabRemotaLayout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel10))
                    .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 151, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(36, Short.MAX_VALUE))
        );
        tabRemotaLayout.setVerticalGroup(
            tabRemotaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, tabRemotaLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(tabRemotaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5)
                    .addComponent(jLabel8))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(tabRemotaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6)
                    .addComponent(jLabel9))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(tabRemotaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7)
                    .addComponent(jLabel10))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton1)
                .addGap(8, 8, 8)
                .addGroup(tabRemotaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4)
                    .addComponent(jButton2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton3)
                .addGap(38, 38, 38))
        );

        tabsConexion.addTab("Conexion: Principal", tabRemota);

        buttonSaveWeb.setText("Guardar Configuracion");
        buttonSaveWeb.setEnabled(false);
        buttonSaveWeb.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonSaveWebActionPerformed(evt);
            }
        });

        DBWeb.setText("---");

        textUserWeb.setNextFocusableComponent(textPassWeb);

        serverWeb.setText("---");

        textServerWeb.setNextFocusableComponent(textUserWeb);

        jLabel13.setText("Base De Datos:");

        buttonTestDBWeb.setText("Probar Conexion");
        buttonTestDBWeb.setEnabled(false);
        buttonTestDBWeb.setNextFocusableComponent(buttonSaveWeb);
        buttonTestDBWeb.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonTestDBWebActionPerformed(evt);
            }
        });

        buttonGetDBWeb.setText("Obtener Bases De Datos");
        buttonGetDBWeb.setNextFocusableComponent(comboDBWeb);
        buttonGetDBWeb.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonGetDBWebActionPerformed(evt);
            }
        });

        textPassWeb.setNextFocusableComponent(buttonGetDBWeb);
        textPassWeb.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                textPassWebActionPerformed(evt);
            }
        });

        jLabel14.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel14.setText("Usuario:");

        comboDBWeb.setEnabled(false);
        comboDBWeb.setNextFocusableComponent(buttonTestDBWeb);
        comboDBWeb.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                comboDBWebActionPerformed(evt);
            }
        });

        jLabel15.setText("Servidor:");

        jLabel16.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel16.setText("Base de Datos:");

        jLabel17.setText("Usuario:");

        jLabel18.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel18.setText("Servidor Web");

        jLabel19.setText("Contraseña:");

        usuarioWeb.setText("---");

        jLabel11.setText("Sufijo:");

        jLabel20.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel20.setText("Sufijo:");

        lblSufijo.setText("---");

        javax.swing.GroupLayout tabLocalLayout = new javax.swing.GroupLayout(tabLocal);
        tabLocal.setLayout(tabLocalLayout);
        tabLocalLayout.setHorizontalGroup(
            tabLocalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(tabLocalLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(tabLocalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(tabLocalLayout.createSequentialGroup()
                        .addGroup(tabLocalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel15)
                            .addComponent(jLabel17))
                        .addGap(34, 34, 34)
                        .addGroup(tabLocalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(textUserWeb)
                            .addComponent(textServerWeb)))
                    .addGroup(tabLocalLayout.createSequentialGroup()
                        .addComponent(jLabel13)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(tabLocalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(buttonSaveWeb, javax.swing.GroupLayout.DEFAULT_SIZE, 183, Short.MAX_VALUE)
                            .addComponent(comboDBWeb, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(tabLocalLayout.createSequentialGroup()
                        .addGroup(tabLocalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel19)
                            .addComponent(jLabel11))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(tabLocalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(textPassWeb)
                            .addComponent(txtSufijo))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(tabLocalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(tabLocalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(tabLocalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, tabLocalLayout.createSequentialGroup()
                                .addComponent(jLabel14)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(usuarioWeb))
                            .addGroup(tabLocalLayout.createSequentialGroup()
                                .addComponent(jLabel18)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(serverWeb)))
                        .addGroup(tabLocalLayout.createSequentialGroup()
                            .addComponent(jLabel16)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(DBWeb))
                        .addComponent(buttonGetDBWeb, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(buttonTestDBWeb, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(tabLocalLayout.createSequentialGroup()
                        .addComponent(jLabel20)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblSufijo)))
                .addGap(73, 73, 73))
        );
        tabLocalLayout.setVerticalGroup(
            tabLocalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, tabLocalLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(tabLocalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel15)
                    .addComponent(textServerWeb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel18)
                    .addComponent(serverWeb))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(tabLocalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel17)
                    .addComponent(textUserWeb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel14)
                    .addComponent(usuarioWeb))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(tabLocalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel19)
                    .addComponent(textPassWeb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel16)
                    .addComponent(DBWeb))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(tabLocalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(txtSufijo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(tabLocalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel20)
                        .addComponent(lblSufijo)))
                .addGap(15, 15, 15)
                .addGroup(tabLocalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(comboDBWeb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel13)
                    .addComponent(buttonGetDBWeb))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(tabLocalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buttonSaveWeb)
                    .addComponent(buttonTestDBWeb))
                .addGap(38, 38, 38))
        );

        tabsConexion.addTab("Conexion: Web", tabLocal);

        jButton4.setText("Salir");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addComponent(tabsConexion, javax.swing.GroupLayout.PREFERRED_SIZE, 519, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(tabsConexion, javax.swing.GroupLayout.PREFERRED_SIZE, 264, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton4)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
if(jComboBox1.isEnabled()){
    try {
        DriverManager.getConnection("jdbc:mysql://"+jTextField1.getText()+"/"+jComboBox1.getSelectedItem(), jTextField2.getText(), String.valueOf(jPasswordField1.getPassword()));
        jButton3.setEnabled(true);
    } catch (SQLException ex) {
Almacen.logger.log(Level.SEVERE, null, ex);    }
}
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        if(!jTextField1.getText().equals("")&&!jTextField1.getText().equals("")){
         try {
                con =  DriverManager.getConnection("jdbc:mysql://"+jTextField1.getText()+":3306",jTextField2.getText(),String.valueOf(jPasswordField1.getPassword()));
                DatabaseMetaData meta = con.getMetaData();
             try (ResultSet res = meta.getCatalogs()) {
                 while (res.next()) {
                     jComboBox1.addItem(res.getString("TABLE_CAT"));
                 }
             }
                con.close();
                jButton2.setEnabled(true);
                jComboBox1.setEnabled(true);
              } catch (SQLException ex) {
Almacen.logger.log(Level.SEVERE, null, ex);              }       
            }   
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
this.dispose();
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
       propiedades.setProperty("baseDatosLocal",String.valueOf(jComboBox1.getSelectedItem()));
       propiedades.setProperty("serverLocal", jTextField1.getText());
       propiedades.setProperty("usuarioLocal", jTextField2.getText());
       propiedades.setProperty("passLocal", String.valueOf(jPasswordField1.getPassword()));
       FileOutputStream os = null;
       try {
            os=new FileOutputStream("Propiedades.properties");
            propiedades.store(os, "Base de Datos Local");
       } catch(IOException ex) {Almacen.logger.log(Level.SEVERE, null, ex); }
            this.dispose();
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jPasswordField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jPasswordField1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jPasswordField1ActionPerformed

    private void buttonSaveWebActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSaveWebActionPerformed
       propiedades.setProperty("baseDatosRemoto",String.valueOf(comboDBWeb.getSelectedItem()));
       propiedades.setProperty("serverRemoto", textServerWeb.getText());
       propiedades.setProperty("usuarioRemoto", textUserWeb.getText());
       propiedades.setProperty("passRemoto", String.valueOf(textPassWeb.getPassword()));
       propiedades.setProperty("sufijo", txtSufijo.getText());
       FileOutputStream os = null;
       try {
            os=new FileOutputStream("Propiedades.properties");
            propiedades.store(os, "Base de Datos Local");
       } catch(IOException ex) {Almacen.logger.log(Level.SEVERE, null, ex); }
            this.dispose();
    }//GEN-LAST:event_buttonSaveWebActionPerformed

    private void buttonTestDBWebActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonTestDBWebActionPerformed
if(comboDBWeb.isEnabled()){
    try {
       // System.out.println("jdbc:mysql://"+textServerWeb.getText()+":3306 "+textUserWeb.getText()+String.valueOf(textPassWeb.getPassword()));

         DriverManager.getConnection("jdbc:mysql://"+textServerWeb.getText()+":3306",textUserWeb.getText(),String.valueOf(textPassWeb.getPassword()));
                        //
         buttonSaveWeb.setEnabled(true);
    } catch (SQLException ex) {
Almacen.logger.log(Level.SEVERE, null, ex);    }
}
    }//GEN-LAST:event_buttonTestDBWebActionPerformed

    private void buttonGetDBWebActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonGetDBWebActionPerformed
        if(!textServerWeb.getText().equals("")&&!textUserWeb.getText().equals("")&&!textPassWeb.getPassword().equals("")){
         try {
                con =  DriverManager.getConnection("jdbc:mysql://"+textServerWeb.getText()+":3306",textUserWeb.getText(),String.valueOf(textPassWeb.getPassword()));
                DatabaseMetaData meta = con.getMetaData();
             try (ResultSet res = meta.getCatalogs()) {
                 while (res.next()) {
                     comboDBWeb.addItem(res.getString("TABLE_CAT"));
                 }
             }
                con.close();
                comboDBWeb.setEnabled(true);
                buttonTestDBWeb.setEnabled(true);
              } catch (SQLException ex) {
Almacen.logger.log(Level.SEVERE, null, ex);              }       
            } 
    }//GEN-LAST:event_buttonGetDBWebActionPerformed

    private void textPassWebActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textPassWebActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_textPassWebActionPerformed

    private void comboDBWebActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboDBWebActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_comboDBWebActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel DBWeb;
    private javax.swing.JButton buttonGetDBWeb;
    private javax.swing.JButton buttonSaveWeb;
    private javax.swing.JButton buttonTestDBWeb;
    private javax.swing.JComboBox comboDBWeb;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPasswordField jPasswordField1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JLabel lblSufijo;
    private javax.swing.JLabel serverWeb;
    private javax.swing.JPanel tabLocal;
    private javax.swing.JPanel tabRemota;
    private javax.swing.JTabbedPane tabsConexion;
    private javax.swing.JPasswordField textPassWeb;
    private javax.swing.JTextField textServerWeb;
    private javax.swing.JTextField textUserWeb;
    private javax.swing.JTextField txtSufijo;
    private javax.swing.JLabel usuarioWeb;
    // End of variables declaration//GEN-END:variables
}
